<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.pro.bean.Groups "%>
<%@ page import="com.pro.bean.Card_Group "%>
<%@ page import="com.pro.bean.Info "%>
<%@ page import="com.wangle.dao.CardGroupImpl "%>
<%@ page import="com.pro.bean.Mark ;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta charset="utf-8" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link href="css/bootstrap.css" rel="stylesheet">
	<link rel="stylesheet" href="css/main.css">

	<script src="js/jquery.js"></script>
	<script src="js/bootstrap.min.js"></script>

	<title>组管理右部</title>
	<script type="text/javascript">
	function deleteCard(cardid){
    var flag=window.confirm("确定删除？");
    if(flag==true)
    $.ajax({
    type:"post",
    url:"CardGroupServlet?&cardid="+cardid,
    data:$("#formright").serialize(), 
    success:function(datas){
    parent.frames["right"].location.reload();
    }
    });
    }	
	</script>
</head>

<body>
<%
ArrayList<Info> cardlist=(ArrayList<Info>) request.getAttribute("cardlist");
Groups group=new Groups();
String groupname=(String)request.getAttribute("groupname");
request.setAttribute("groupname",groupname);


int intPageSize=6;  //每页显示的记录数
	int currPageBegin;  //起始记录索引	
	int AllPage;   //总页数
	int requestPage;     //用户请求页码
	String strPage;
	
	 strPage=request.getParameter("pagenumber");
	 if(strPage==null)
	 {
	 requestPage=1;
	 }
	 else
	 {
	    requestPage=Integer.parseInt(strPage);
	    if(requestPage<1)
	   {
	    requestPage=1;
	    }
	 
	 }
	 AllPage=(cardlist.size()+intPageSize-1)/intPageSize;
	 if(requestPage>AllPage)
	    requestPage=AllPage;
	currPageBegin=requestPage*intPageSize-intPageSize;	
if(cardlist==null||cardlist.size()==0){
%>
<br/>
<br/>
<%
out.print(groupname); 
out.println("组内没有名片");
//code=URLEncoder.encode(p_code, "utf-8") 
}else{

 %>
<form method="get" action="CardGroupServlet" name="formright" target="right" id="formright">
   <div id="wrightdiv"  style="width:500px">
	<legend>
	<font color="#FF0000" size="2"><br>
	所属名片一览</font>
	</legend>
	<table class="table table-bordered table-hover">
		<tr>
		     <th>删除</th>
			<th>名片</th>
			<th>公司名</th>
			<th>姓名</th>
			<th>所在组</th>
		</tr>
		<%
			//for(int i=0;i<cardlist.size();){
			for(int i=currPageBegin; i < requestPage*intPageSize&&i<cardlist.size();i++){
		 %>
		<tr>
		<td><a href="javascript:deleteCard(<%=cardlist.get(i).getCardid() %>)">删除</a></td>
			 <td><a href="servlet/showServlet?cardid=<%=cardlist.get(i).getCardid() %>" target="_blank">名片</a></td>
			<td><%=cardlist.get(i).getCmp() %></td>
			<td><%=cardlist.get(i).getFirstName()%></td>
		
			<td><%=groupname%></td>
		</tr>
		<%} %>
	</table>	
</div>
</form>
<%
}
 %>
 
  <center>
                               共<%=AllPage%>页&nbsp;第<%=requestPage%>页        
          <%if(requestPage>1){ %>
            <a href="jsp/groupRight.jsp?pagenumber=<%=requestPage-1%>">上一页</a>
            <%}else{ %>
                                    上一页
         <%}%>
         <%if(requestPage<AllPage){ %>
        <a href="jsp/groupRight.jsp?pagenumber=<%=requestPage+1%>">下一页</a>
            <%}else{ %>
                                   下一页
         <%}%>
         </center>      
 
</body>

</html>

